<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-goodsinfo-edit" th:object="${goodsinfo}">
            <input id="goodsinfoId" name="goodsinfoId" th:field="*{goodsinfoId}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">所属分类：</label>
				<div class="col-sm-8">
					<input id="mallcategoryId" name="mallcategoryId" th:field="*{mallcategoryId}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">商品价格：</label>
				<div class="col-sm-8">
					<input id="goodsPrice" name="goodsPrice" th:field="*{goodsPrice}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">会员价格：</label>
				<div class="col-sm-8">
					<input id="memberPrice" name="memberPrice" th:field="*{memberPrice}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">积分价格：</label>
				<div class="col-sm-8">
					<input id="integralPrice" name="integralPrice" th:field="*{integralPrice}" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">展示优先级：</label>
				<div class="col-sm-8">
					<input id="sortPriority" name="sortPriority" th:field="*{sortPriority}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">库存数量：</label>
				<div class="col-sm-8">
					<input id="kuCun" name="kuCun" th:field="*{kuCun}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<input id="status" name="status" th:field="*{status}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">拼单开启：</label>
				<div class="col-sm-8">
					<input id="pindan" name="pindan" th:field="*{pindan}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">商品描述：</label>
				<div class="col-sm-8">
					<input id="goodsDescribe" name="goodsDescribe" th:field="*{goodsDescribe}" class="form-control" type="text">
					<div id="editor" class="summernote"></div>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/goodsinfo";
		$("#form-goodsinfo-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				var sHTML = $('.summernote').summernote('code');
				$("#goodsDescribe").val(sHTML);
	            $.operate.save(prefix + "/edit", $('#form-goodsinfo-edit').serialize());
	        }
	    }
		$(function() {
			$('.summernote').summernote({
				height : '220px',
				lang : 'zh-CN',
				callbacks: {
					onImageUpload: function (files) {
						sendFile(files[0], this);
					}
				}
			});
			var content = $("#goodsDescribe").val();
			$('#editor').summernote('code', content);
		});

		// 上传文件
		function sendFile(file, obj) {
			var data = new FormData();
			data.append("file", file);
			$.ajax({
				type: "POST",
				url: ctx + "common/upload",
				data: data,
				cache: false,
				contentType: false,
				processData: false,
				dataType: 'json',
				success: function(result) {
					if (result.code == web_status.SUCCESS) {
						var imageUrl = response.msg;
						$(obj).summernote('editor.insertImage', ctx+"profile/"+imageUrl, result.fileName);
					} else {
						$.modal.alertError(result.msg);
					}
				},
				error: function(error) {
					$.modal.alertWarning("图片上传失败。");
				}
			});
		}
	</script>
</body>
</html>
